package edu.ccut.saturn.studio.wfg.dialog.userdialog.treeoperate;

import java.util.Map;
import java.util.HashMap;
import java.util.Properties;
import java.util.Enumeration;
import java.io.IOException;

public class SqlLoader {
    private static Map<String,String> sqlMap;

    static {
        initalSqlMap();
    }

    private SqlLoader() {
    }

    public static String getSqlCode(String key) {
        return (String) sqlMap.get(key);
    }

    private static void initalSqlMap() {
        sqlMap = new HashMap<String,String>();

        Properties properties = new Properties();

        try {
            properties.load(SqlLoader.class.getResourceAsStream("sqlLoader.properties"));
        } catch (IOException e) {
            e.printStackTrace(); 
        }

        Enumeration<?> enumeration = properties.propertyNames();
        while (enumeration.hasMoreElements()) {
            String name = (String) enumeration.nextElement();
            sqlMap.put(name, properties.getProperty(name));
        }
    }
}
